package com.sdcx.agrobank.base;

import com.blankj.utilcode.util.ToastUtils;
import com.sdcx.agrobank.net.HttpRetrofitUtil;

public abstract class BaseMvpActivity<M extends BaseContrat.IBaseModel,P extends BaseContrat.BasePresenter> extends BaseActivity implements BaseContrat.IBaseView {

    public P presenter;
    public M baseModel;

    //绑定
    @Override
    public void init() {
        boolean isnetwork = HttpRetrofitUtil.get().isnetwork(this);
        if (!isnetwork){
            ToastUtils.showShort("未连接网络");
        }
        presenter = (P) getPresenter();
        if (presenter!=null){
            baseModel = (M) presenter.getModel();
            if (baseModel!=null){
                presenter.Attach(baseModel,this);
            }
        }
    }
    //清除
    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.onDestroy();
    }
}